//写验证规则
const joi = require('joi')
    //用户名验证规则
const username = joi.string().alphanum().min(3).max(10).required()
    //密码验证规则
const password = joi.string().pattern(/^[\S]{6,12}$/).required()
const email = joi.string().email({ minDomainSegments: 2, tlds: { allow: ['com', 'net', ] } })
const mobile = joi.string().pattern(/^1[3-9]\d{9}$/)

//登录表单验证规则对象
exports.login_schema = {
    body: {
        username,
        password,
    }
}
exports.user_create_schema = {
    body: {
        username,
        password,
        email,
        mobile,
    }
}
exports.user_update_schema = {
    body: {
        email,
        mobile
    }
}